package com.game.sprite.components;

import java.util.ArrayList;

/**
* @author oven:
* @version 创建时间：2012-12-1 上午9:01:04
* list 数据集
*/
public class BasicListData<T extends BasicListItem> {
	protected  ArrayList<T> data;
	
	public BasicListData(ArrayList<T> data){
		this.data=data;
		if(data==null){
			data=new ArrayList<T>();
		}
	}
	
	public BasicListData(){
		data=new ArrayList<T>();
	}
	
	public synchronized void addItem(T item){
		data.add(item);
	}
	
	public synchronized void removeItem(BasicListItem item){
		data.remove(item);
	}
	
	public synchronized void removeItem(int index){
		data.remove(index);
	}
	
	public synchronized void addItem(int index , T item){
		data.add(index, item);
	}

	public ArrayList<T> getData() {
		return data;
	}

	public synchronized  void setData(ArrayList<T> data) {
		this.data = data;
	}
	
	public synchronized T getItem(int index){
		return data.get(index);
	} 
	
	public synchronized T get(int index){
		return getItem(index);
	}
	
	public int size(){
		return data.size();
	}
}



